package com.open.capacity.forum.feign;

import com.open.capacity.common.constant.ServiceNameConstant;
import com.open.capacity.common.model.FileInfo;
import com.open.capacity.forum.feign.impl.FileServiceFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 蒋鑫
 * @version 2021/3/1
 * 通过feign远程调用文件上传模块的接口
 */
@FeignClient(value = ServiceNameConstant.FILE, fallbackFactory = FileServiceFallback.class, decode404 = true)
public interface FileService {
    /**
     * 文件上传
     * 根据fileType选择上传方式
     *
     * @param file
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/files-anon",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    FileInfo upload(@RequestPart("file") MultipartFile file) throws Exception;
}